<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>主题列表</title>
    <link rel="stylesheet/less" href="../../../static/css/index.less"/>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/css/jquery.pagination.css"/>
    <script src="../../../static/js/jquery-1.12.3.js"></script>
    <script src="../../../static/js/less.min.js"></script>
    <script src="../../../static/layui/layui.js"></script>
    <script src="../../../static/js/ajaxfileupload.js"></script>
    <script src="../../../static/layer/layer.js"></script>
</head>
<style>
    .table_td_img {
        width: 50px;
        height: 50px;
        padding: 3px
    }
</style>
<body class="layui-layout-body">

{% include "admin/top.html" %}
{% include "admin/left.html" %}

<div id="box" class="fl">
    <div class="content">
        <h3><a>主题列表</a></h3>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th>主题ID</th>
                <th>主题名称</th>
                <th>添加时间</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody id="result">
            <tr>
                {% if res %}
                    {% for d in res %}
                        <tr>
                            <td>{{ d.sid }}</td>
                            <td>{{ d.typeName }}</td>
                            <td>{{ d.addTime }}</td>
                            <td>
                                {% if d.status == 1 %}
                                激活
                                {% else %}
                                禁用
                                {% endif %}
                            </td>
                            <td><a onclick="cilck_btn({{ d.sid }}, 0)" class="course_commit" name="edit">编辑</a>
                                {% if d.status == 1 %}
                                <a onclick="cilck_btn({{ d.sid }}, 2)" class="course_commit" name="lock">锁定</a>
                                {% endif %}
                                {% if d.status == 0 %}
                                <a onclick="cilck_btn({{ d.sid }}, 1)" class="course_commit" name="unlock">激活</a>
                                {% endif %}
                                <a onclick="cilck_btn({{ d.sid }}, 3)" class="course_commit" name="delete">删除</a>
                            </td>
                        </tr>
                    {% endfor %}
                    {% else %}
                    <tr>
                        <td colspan="5">暂无数据</td>
                    </tr>

                {% endif %}

            </tbody>
        </table>
            <div class="ui-pagination-container">

            </div>
    </div>
</div>
<input type="hidden" id="p" value="1">
</body>
</html>

<script>

    function cilck_btn(uid, pid){
        if (pid == 0){
            location.href = '/admin/subject_detail.html?sid=' + uid;
            return false;
        }else if(pid == 1){
            var content = "激活主题";
        }else if(pid == 2){
            var content = '禁用主题';
        }else if(pid == 3){
            var content = '删除主题';
        }else {
            return false;
        }
        layer.open({
                content: content,
                btn: ['确认', '取消'],
                yes: function () {
                    $.ajax({
                        url: "/admin/update_subject_post",
                        type: "POST",
                        data: {
                            sid: uid,
                            pid: pid
                        },
                        success: function (data) {
                            if (data.status == 1) {
                                layer.msg("操作成功", {time: 2000}, function () {
                                    location.reload();
                                })
                            } else {
                                layer.msg("操作失败！")
                            }
                        }
                    })
                },
                btn2: function (index, layero) {

                }
                ,
                cancel: function () {
                    //右上角关闭回调

                }
            });
    }

</script>


